#define SIL_SIM_BASE_MF4_FILE

#include <cstdint>
#include <vector>

#include "RecorderIF.h"
#include "Simulation/nodeData.h"

inline static void createMeasurement(const std::string& deviceName, const uint64_t address, const std::string& observeSignalName, const Mf4Recorder::SignalBaseInfo::TYPE type,
									 const double factor, const double offset, const std::string& unit,
									 std::vector<Mf4Recorder::SignalBaseInfo>& signalBaseInfo)
{
	Mf4Recorder::SignalBaseInfo temp;

	temp.deviceName = deviceName;
	temp.address = address;
	temp.name = observeSignalName;
	temp.type = type;

	temp.factor = factor;
	temp.offset = offset;
	temp.unit = unit;

	signalBaseInfo.emplace_back(temp);
}

inline static void createMeasurement(const std::string& deviceName, const uint64_t address, const std::string& observeSignalName, const Mf4Recorder::SignalBaseInfo::TYPE type,
									 const double factor, const double offset, const std::string& unit,
									 const std::vector<Mf4Recorder::SignalBaseInfo::EnumKeyValue>& enumKeyValue, std::vector<Mf4Recorder::SignalBaseInfo>& signalBaseInfo)
{
	createMeasurement(deviceName, address, observeSignalName, type, factor, offset, unit, signalBaseInfo);

	signalBaseInfo.back().enumKeyValue = enumKeyValue;
}


void addSignal_Sil_RoadMessage(std::vector<Mf4Recorder::SignalBaseInfo>& signalBaseInfo)
{
	std::vector<Mf4Recorder::SignalBaseInfo::EnumKeyValue> keyValue;
	Mf4Recorder::SignalBaseInfo::EnumKeyValue temp;

	createMeasurement("Sil_RoadMessage",
					 (uint64_t)&NodeData::SIL_roadMessage.timeStamp,
					 "SIL_roadMessage.TimeStamp",
					 Mf4Recorder::SignalBaseInfo::TYPE::U64, 1.0, 0.0, std::string(), signalBaseInfo);

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].id,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].id",
						 Mf4Recorder::SignalBaseInfo::TYPE::U8, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	keyValue.clear();
	temp.key = "UNKNOWN";
	temp.value = 0;
	keyValue.emplace_back(temp);

	temp.key = "DASHED";
	temp.value = 1;
	keyValue.emplace_back(temp);

	temp.key = "SOLID";
	temp.value = 2;
	keyValue.emplace_back(temp);

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].type,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].type",
						 Mf4Recorder::SignalBaseInfo::TYPE::U8, 1.0, 0.0, std::string(), keyValue, signalBaseInfo);
	}

	keyValue.clear();
	temp.key = "UNKNOWN";
	temp.value = 0;
	keyValue.emplace_back(temp);

	temp.key = "YELLOW";
	temp.value = 1;
	keyValue.emplace_back(temp);

	temp.key = "WHITE";
	temp.value = 2;
	keyValue.emplace_back(temp);

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].color,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].color",
						 Mf4Recorder::SignalBaseInfo::TYPE::U8, 1.0, 0.0, std::string(), keyValue, signalBaseInfo);
	}

	keyValue.clear();
	temp.key = "UNKNOWN";
	temp.value = 0;
	keyValue.emplace_back(temp);

	temp.key = "LEFT_LEFT";
	temp.value = 1;
	keyValue.emplace_back(temp);

	temp.key = "LEFT";
	temp.value = 2;
	keyValue.emplace_back(temp);

	temp.key = "RIGHT";
	temp.value = 3;
	keyValue.emplace_back(temp);

	temp.key = "RIGHT_RIGHT";
	temp.value = 4;
	keyValue.emplace_back(temp);

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].position,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].position",
						 Mf4Recorder::SignalBaseInfo::TYPE::U8, 1.0, 0.0, std::string(), keyValue, signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].a0,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].a0",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].a1,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].a1",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].a2,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].a2",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].a3,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].a3",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].start,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].start",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].end,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].end",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

	for(uint32_t i = 0U; i < 8U; i++)
 	{
 		createMeasurement("Sil_RoadMessage",
						 (uint64_t)&NodeData::SIL_roadMessage.line[i].width,
						 "SIL_roadMessage.line[" + std::to_string(i) + "].width",
						 Mf4Recorder::SignalBaseInfo::TYPE::F32, 1.0, 0.0, std::string(), signalBaseInfo);
	}

}
